package Grasnador.Grasnador0.DTO;

import java.sql.Date;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import Grasnador.Grasnador0.Generic.GenericDTO;

@Entity
@Table(name = "grasnado")
public class Grasnado extends GenericDTO {
	@Column(length = 140)
	private String content;
	private Date time;
	
	@ManyToOne
	@JoinColumn (name = "user_id")
	private User author;
	
	@ManyToMany (fetch = FetchType.EAGER, mappedBy = "regrasnados")
	private Set<User> regrasnadores = new HashSet<User>();

	public Set<User> getRegrasnadores() {
		return regrasnadores;
	}

	public void setRegrasnadores(Set<User> regrasnadores) {
		this.regrasnadores = regrasnadores;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Grasnado [content=");
		builder.append(content);
		builder.append(", time=");
		builder.append(time);
		builder.append(", author=");
		builder.append(author.getId());
		builder.append(", regrasnadores=");
		builder.append(regrasnadores);
		builder.append(", id=");
		builder.append(id);
		builder.append("]");
		return builder.toString();
	}
}
